#{extends 'backend_main.html' /}
#{set title:'后台管理' /}
<iframe id="iframe1" name="iframe1" style="display: none;"></iframe>
<div class="x-nav">
    <span class="layui-breadcrumb"><a>首页</a><a>订单管理</a><a><cite>订单列表</cite></a></span>
    <a class="layui-btn layui-btn-sm" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.reload();" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
  <div class="layui-row">
    <form class="layui-form layui-col-md12 x-so" id="form1" action="/BackendCenter/orderList">
        <input type="hidden" id="currPage" name="currPage"/>
        <input type="hidden" id="pageSize" name="pageSize"/>
        <input class="layui-input" placeholder="开始日" name="startTime" id="start" value="${startTime}">
        <input class="layui-input" placeholder="截止日" name="endTime" id="end" value="${endTime}">
        <input type="text" name="username"  placeholder="请输入客户姓名" autocomplete="off" class="layui-input" value="${username}">
        <div class="layui-input-inline">
            #{select name:'pay_status', value:pay_status, id:'pay_status' }
                #{option }订单状态#{/option}
                #{option 0}待付款#{/option}
                #{option 1}已付款#{/option}
            #{/select}
        </div>
        <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
    </form>
  </div>
  <xblock>
    <button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>
    <button class="layui-btn" onclick="x_admin_show('添加客户','./orderEdit?${utils.Constants.viewAdd}')"><i class="layui-icon"></i>添加</button>
    <button class="layui-btn" onclick="x_admin_show('导入数据','./orderImport?v=show')"><i class="layui-icon"></i>导入Excel</button>
      <button class="layui-btn" onclick="exportExcel('./orderImport?v=export')"><i class="layui-icon"></i>导出Excel</button>
      <script>
          function exportExcel(Url) {
              layer.msg("正在导出excel...");
              iframe1.location.href =Url;
          }
      </script>
    <span class="x-right" style="line-height:40px">共有数据：${pageBean?.totalCount} 条</span>
  </xblock>
  <table class="layui-table">
    <thead>
      <tr>
        <th><div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div></th>
          <th>ID</th>
        <th>所属业务员</th>
        <th>客户姓名</th>
        <th>烫画图片</th>
        <th>下单时间</th>
        <th>价格</th>
        <th>张数</th>
        <th>金额</th>
        <th>付款状态</th>
        <th >客户级别</th>
        <th >客户来源</th>
        <th >创建日期</th>
        <th >操作</th>
        </tr>
    </thead>
    <tbody id="tableImgs">
    #{list pageBean?.page}
      <tr>
        <td>
          <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='${_?.id}'><i class="layui-icon">&#xe605;</i></div>
        </td>
          <td>${_?.id}</td>
        <td>${_?.getBusinessId()}</td>
        <td>${_?.customer_name}</td>
        <td><img src="/FileController/images?uuid=${_?.filename}" height="80" onclick="layerPhotos({src:this.src})"></td>
        <td>${_?.getBuy_date()}</td>
        <td>${_?.single_price}</td>
        <td>${_?.all_count}</td>
        <td>${_?.getSum_price()}</td>
        <td>${_?.getPay_status()}</td>
          <td>${_?.customer_level}</td>
          <td>${_?.customer_source}</td>
          <td>${_?.create_date}</td>
        <td class="td-manage">
            <a title="详情"  onclick="x_admin_show('详情','orderEdit?id=${_?.id}&v=show')" href="javascript:;" class="layui-btn layui-btn-xs"> 详情</a>
            <a title="编辑"  onclick="x_admin_show('编辑','orderEdit?id=${_?.id}&${utils.Constants.viewUpdate}')" href="javascript:;" class="layui-btn layui-btn-xs"> 编辑</a>
        </td>
      </tr>
    #{/list}
    </tbody>
  </table>
  #{page currPage:pageBean?.currPage,totalCount:pageBean?.totalCount,pageSize:pageBean?.pageSize,theme:2,style:1 /}
</div>
<script>
    /* 条件搜素查询 */
    function showPage(currPage, pageSize){
        $("#currPage").val(currPage);
        $("#pageSize").val(pageSize);
        $("#form1").submit();
    }
  layui.use(['laydate','layer'], function(){
    var laydate = layui.laydate;
    var layer = layui.layer;
    //执行一个laydate实例
    laydate.render({
      elem: '#start' //指定元素
        ,type: 'date'
    });
    //执行一个laydate实例
    laydate.render({
      elem: '#end' //指定元素
        ,type: 'date'
    });
      layer.ready(function(){ //为了layer.ext.js加载完毕再执行
          layer.photos({
              photos: '#tableImgs'
              //,shift: 5 //0-6的选择，指定弹出图片动画类型，默认随机
          });
      });
  });
  function delAll (argument) {
    var data = tableCheck.getData();
    if(data==""){
        layer.msg("请先选择要删除的条目");
        return;
    }
    layer.confirm('确认要删除吗？'+data,function(index){
        $.ajax({
            type:"POST",                      //请求类型
            url:"./orderEdit?${utils.Constants.postDelete}",                 //URL
            data:"ids="+data,                  //传递的参数
            dataType:"json",                 //返回的数据类型
            success:function(data){          //data就是返回的json类型的数据
                console.log(data);
                window.location.reload();
            },
            error:function(data){
            }
        });
    });
  }
</script>